package chapter6;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 计算未来投资价值
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc6_7 {
	
	public static double futureInvestmentValue(
			double investmentAmount,double monthlyInterestRate, int years) {
		
		return (investmentAmount*Math.pow( (1+monthlyInterestRate),       years*12  ));
		
	}
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter invest amount :  ");
		double investAmount=input.nextDouble();
		System.out.print("Enter anual interest rate in percentage: ");
		double monthlyInterestRate=input.nextDouble()/1200.0;		//不是除以12.0，因为这是个百分数
//		System.out.print("Enter number of years: ");
//		int years=input.nextInt();
		
		System.out.print("Years\t\t\tFuture Value\n");
		for(int i=1;i<=30;i++) {
			System.out.printf("%-2d\t\t\t%9.2f\n",i,futureInvestmentValue(investAmount,monthlyInterestRate,i));
		}
		
		
	}

}
